package com.jiang.dao.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.jiang.dao.INewsDAO;
import com.jiang.vo.News;

@Repository
public class NewsDAOImpl extends SqlSessionDaoSupport implements INewsDAO {

	// 不用属性或者setter注入，另一种注入使用构造函数注入
	@Autowired
	public NewsDAOImpl(SqlSessionFactory sqlSessionFactory) {
		super.setSqlSessionFactory(sqlSessionFactory);
	}

	@Override
	public Boolean doCreate(News news) throws SQLException {
		return super.getSqlSession().insert("com.jiang.vo.mapping.newsNS.doCreate", news) > 0;
	}

	@Override
	public List<News> findSplit(Map<String, Object> param) throws Exception {
		return super.getSqlSession().selectList("com.jiang.vo.mapping.newsNS.findSplit", param);
	}

}
